package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.User;
import com.atguigu.jxc.service.DamageListGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * ClassName: DamageListGoodsController
 * Package: com.atguigu.jxc.controller
 * Description:
 *
 * @Author 梅超凡
 * @Create 2025/2/22 14:56
 * @Version 1.0
 */
@RestController
@RequestMapping("/damageListGoods")
public class DamageListGoodsController {


    @Autowired
    private DamageListGoodsService damageListGoodsService;

    /**
     * 保存报损单
     * @param damageNumber 报损单号
     * @param damageDate 日期
     * @param damageListGoodsStr 报损单商品信息
     * @param remarks 备注
     * @param session session
     * @return ServiceVO
     */
    @PostMapping("/save")
    public ServiceVO<Object> saveDamageListGoods(
            String damageNumber,
            String damageDate,
            String damageListGoodsStr,
            String remarks,
            HttpSession session) {
        User user = (User) session.getAttribute("currentUser");
        return damageListGoodsService.saveDamageListGoods(damageNumber, damageDate, damageListGoodsStr, remarks, user);
    }

    /**
     * 报损单商品列表
     * @param sTime 开始时间
     * @param eTime 结束时间
     * @return Map<String,Object>
     */
    @PostMapping("/list")
    public Map<String, Object> listDamageList(String sTime, String eTime) {
        return damageListGoodsService.listDamageList(sTime, eTime);
    }

    @PostMapping("/goodsList")
    public Map<String, Object> goodsList(Integer damageListId) {
        return damageListGoodsService.goodsList(damageListId);
    }
}
